package com.shop.admin.controller;

import com.shop.Result.LdbzResult;
import com.shop.admin.service.AdminPicService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;
import org.springframework.web.servlet.mvc.support.RedirectAttributes;

import javax.servlet.http.HttpServletRequest;

@RestController
@RequestMapping("/admin/pic/service")
public class AdminPictureController {

    private static final Logger looger = LoggerFactory.getLogger(AdminPictureController.class);

    @Autowired
    private AdminPicService adminPicService;

    @RequestMapping(value="/upload",method= RequestMethod.GET)
    public LdbzResult multifileUpload(@RequestParam("file") MultipartFile file,
                                      HttpServletRequest request, RedirectAttributes redirectAttributes){
        return adminPicService.uploadFile(file,request,redirectAttributes);
    }
}
